import { createRouter, createWebHistory } from 'vue-router'
import NetworkDashboard from '../views/NetworkDashboard.vue'

const routes = [
  {
    path: '/',
    name: 'dashboard',
    component: NetworkDashboard,
    meta: {
      title: '网络监控仪表板'
    }
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/'
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

// 路由前置守卫，设置页面标题
router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '网络监控系统';
  next();
})

export default router